<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>在线填表</h2>
        <ol class="breadcrumb">
            <li>
                <a href="#">首页</a>
            </li>

            <li class="active">
                <strong>在线填表</strong>
            </li>
        </ol>
    </div>

</div>

<div class="wrapper wrapper-content animated fadeInRight ecommerce">

    <div class="ibox-content m-b-sm border-bottom" id="form1">
        <div class="row">
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="lessor_telephone">出租人电话</label>
                    <input type="text" id="lessor_telephone" name="lessor_telephone" placeholder="电话"
                           class="form-control">
                </div>
            </div>

            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="lessor_name">出租人姓名/单位名称</label>
                    <input type="text" id="lessor_name" name="lessor_name" placeholder="出租人姓名/单位名称"
                           class="form-control">
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label">出租人类型</label>
                    {:W('parts/op',['name'=>'lessor_type','key'=>'lty','value'=>''])}
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="lessor_identity">出租人证件号</label>
                    <input type="text" id="lessor_identity" name="lessor_identity" placeholder="证件号"
                           class="form-control">
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="renter_telephone">承租人电话</label>
                    <input type="text" id="renter_telephone" name="renter_telephone" placeholder="承租人电话"
                           class="form-control">
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="renter_name">承租人姓名</label>
                    <input type="text" id="renter_name" name="renter_name" placeholder="承租人姓名"
                           class="form-control">
                </div>
            </div>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="renter_identity">承租人证件号</label>
                    <input type="text" id="renter_identity" name="renter_identity" placeholder="承租人证件号"
                           class="form-control">
                </div>
            </div>


        </div>
        <div class="row">
            <div class="col-sm-6">
                <!--<a class="btn btn-success btn-outline" href="#{:U('form')}">-->
                <!--<i class="fa fa-edit"></i>-->
                <!--<span class="bold">添加</span>-->
                <!--</a>-->
            </div>
            <div class="col-sm-6 text-right">
                <button class="btn btn-default" data-op="reset">
                    <i class="fa fa-refresh"></i>
                    <span class="bold">重置</span>
                </button>
                &nbsp;
                &nbsp;
                <button class="btn btn-primary" data-op="search">
                    <i class="fa fa-search"></i>
                    <span class="bold">查询</span>
                </button>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-content">
                    <table class="footable table table-stripped toggle-arrow-tiny" id="footable">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        var table = YFootTable.create('#footable', {
            baseUrl: "{:U('OnlineWrite/')}",
            searchForm: '#form1',
            columns: [
                {name: 'lty__lessor_type', title: '出租人类型', sortable: true}
                , {name: 'lessor_name', title: '出租人姓名/单位名称', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'lessor_identity', title: '出租人证件号', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'lessor_postcode', title: '出租人邮编', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'lessor_telephone', title: '出租人电话', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'lessor_address', title: '出租人通信地址', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'auth__status', title: '审核状态', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'lease_area', title: '房屋坐落地址', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'lease_address', title: '详细地址', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'lease_measure', title: '租赁面积', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'lease_price', title: '月租金', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'lease_start_date', title: '租赁开始日期', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'lease_end_date', title: '租赁结束日期', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'owner_name', title: '产权人或合法使用人', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'material_name', title: '产权（使用权）材料名称及号码', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'owner_identity', title: '产权人证件号', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'lease_trustee', title: '受委托人', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'lease_trustee_phone', title: '受委托人电话', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'lease_trustee_identity', title: '受委托人证件号', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'renter_name', title: '承租人姓名', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'renter_identity', title: '承租人证件号', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'renter_postcode', title: '承租人邮编', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'renter_telephone', title: '承租人电话', sortable: true, breakpoints: 'xs sm md'}
                , {name: 'renter_address', title: '承租人通讯地址', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'rent_trustee', title: '受委托人', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'rent_trustee_phone', title: '受委托人电话', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'rent_trustee_identity', title: '受委托人证件号', sortable: true, breakpoints: 'xs sm md lg'}
                , {name: 'create_time', title: '提交时间', sortable: true, breakpoints: 'xs sm md lg'}
            ],
            actions: [
                {
                    text: '下载',
                    token:'download',
                    handler: function (row) {
                        YMessager.confirm({
                            title: "确定下载《" + row.lessor_name + "》填表吗?",
                            text: "",
                            showLoaderOnConfirm: false
                        }, function () {
                            YMessager.toast('操作成功');
                            location.href = "{:U('download')}?id=" + row.id;
                        });
                    }
                },
                {
                text: '通过',
                    token:'accept',
                handler: function (row) {
                    YMessager.confirm({
                        title: "确定审核通过所选记录吗?",
                        text: "审核通过后,用户会收到微信推送"
                    }, function () {
                        $.post("{:U('setAuth')}", {
                            status: 1,
                            id: row.id
                        }, function (rt) {
                            if (rt.status == 1) {
                                table.loadData();
                                YMessager.toast('操作成功');
                            } else {
                                YMessager.alert(rt.info);
                            }
                        }, 'json');
                    });
                }
            }, {
                text: '拒绝',
                    token:'reject',
                handler: function (row) {
                    swal({
                                title: "审核拒绝",
                                text: "审核拒绝后,用户会收到微信推送",
                                type: "input",
                                showCancelButton: true,
                                closeOnConfirm: false,
                                confirmButtonText: "确定",
                                cancelButtonText: '取消',
//                                animation: "slide-from-top",
                                inputPlaceholder: "在这输入理由",
                                showLoaderOnConfirm: true
                            },
                            function (inputValue) {
                                if (inputValue === false) return false;
                                if (inputValue === "") {
                                    swal.showInputError("拒绝的理由不能为空");
                                    return false
                                }
                                $.post("{:U('setAuth')}", {
                                    reason: inputValue.trim(),
                                    status: 2,
                                    id: row.id
                                }, function (rt) {
                                    if (rt.status == 1) {
                                        table.loadData();
                                        YMessager.toast('操作成功');
                                    } else {
                                        YMessager.alert(rt.info);
                                    }
                                }, 'json');

                            });
                }
            }, 'view', 'edit', 'remove']
        });
    });
</script>